<%--
  Created by IntelliJ IDEA.
  User: yanchao
  Date: 2021/11/7
  Time: 下午4:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>贷款管理 - 助学贷款管理系统</title>
    <link rel="stylesheet" href="./static/layui/css/layui.css">
    <link rel="stylesheet" href="./static/admin/css/style.css">
    <script src="./static/layui/layui.js"></script>
    <script src="./static/js/jquery-3.3.1.min.js"></script>
    <script src="./static/js/vue.min.js"></script>
    <script src="./static/admin/js/userConfig.js"></script>
</head>
<body class="p20">
<div class="layui-row">
    <form class="form-inline" action="" method="get">
        <div class="layui-col-lg8">
            <div class="layui-input-inline" style="width: 300px">
                <input type="text" name="realname" value="" placeholder="姓名" class="layui-input key">
            </div>
            <button type="submit" class="layui-btn sou">查询</button>
        </div>
    </form>
</div>

<table class="layui-table layui-form">

    <thead>
    <tr>
        <th>ID</th>
        <th>项目名称</th>
        <th>姓名</th>
        <th>年龄</th>
        <th>贷款总额</th>
        <th>申请时间</th>
        <th>审核状态</th>
        <th>还款状态</th>
        <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${sessionScope.allApply}" var="apply" varStatus="status">
        <tr class="id36567">
            <td>${apply.id}</td>
            <td>${apply.project}</td>
            <td>${apply.user.realname}</td>
            <td>${apply.user.age}</td>
            <td>${apply.amount}</td>
            <td><fmt:formatDate value="${apply.applydate}" type="date" pattern="yyyy-MM-dd"/></td>
            <c:if test="${apply.status == 0}"><td>待审核</td></c:if>
            <c:if test="${apply.status == 1}"><td>已审核</td></c:if>
            <c:if test="${apply.status == 2}"><td>未通过</td></c:if>
            <c:if test="${apply.repaystatus == 0}"><td>待还款</td></c:if>
            <c:if test="${apply.repaystatus == 1}"><td>已还款</td></c:if>
            <c:if test="${apply.repaystatus == 2}"><td>已放款</td></c:if>
            <c:if test="${apply.repaystatus == 3}"><td>未放款</td></c:if>
            <c:if test="${apply.repaystatus == 4}"><td>已完成</td></c:if>
            <td>
                <c:if test="${apply.repaystatus == 4}"><button type="button" class="layui-btn layui-btn-sm layui-btn-disabled" onclick="">发放贷款</button></c:if>
                <c:if test="${apply.repaystatus == 0}"><button type="button" class="layui-btn layui-btn-sm layui-btn-disabled" onclick="">发放贷款</button></c:if>
                <c:if test="${apply.repaystatus == 1}"><button type="button" class="layui-btn layui-btn-sm layui-btn-disabled" onclick="">发放贷款</button></c:if>
                <c:if test="${apply.repaystatus == 2}"><button type="button" class="layui-btn layui-btn-sm layui-btn-disabled" onclick="">发放贷款</button></c:if>
                <c:if test="${apply.repaystatus == 3 and apply.status == 0}"><button type="button" class="layui-btn layui-btn-sm layui-btn-disabled" onclick="">发放贷款</button></c:if>
                <c:if test="${apply.repaystatus == 3 and apply.status == 2}"><button type="button" class="layui-btn layui-btn-sm layui-btn-disabled" onclick="">发放贷款</button></c:if>
                <c:if test="${apply.repaystatus == 3 and apply.status == 1}"><button type="button" class="layui-btn layui-btn-sm" onclick="adminGrantApply(${apply.id})">发放贷款</button></c:if>
                <button type="button" class="layui-btn layui-btn-sm" onclick="applyInfo(${apply.id},${apply.userid})">申请表</button>
                <button type="button" class="layui-btn layui-btn-sm" onclick="contract(${apply.id})">合同</button>
                <button type="button" class="layui-btn layui-btn-danger layui-btn-sm" onclick="del(${apply.id})">删除</button>
            </td>
        </tr>
    </c:forEach>
    </tbody>
</table>
<script src="./static/admin/js/script.js"></script>
<script type="text/javascript" language="javascript">
    function applyInfo(id,userid) {
        window.location.href="/applyInfo.do?id=" + id +"&userid=" + userid;
    }
    function contract() {
        window.location.href="/contract";
    }
    function del(id) {
        var message=confirm("你确定要删除这条信息吗？");
        if(message===true)
        {
            window.location.href="/adminDeleteApply.do?id=" + id;
        }
        else if(message==false)
        {
            window.location.href="/adminApplyList.do";
        }
    }
    function adminGrantApply(id) {
        var message=confirm("你确定要发放贷款吗？");
        if(message===true)
        {
            window.location.href="/adminGrantApply.do?id=" + id;
        }
        else if(message==false)
        {
            window.location.href="/adminApplyList.do";
        }
    }
</script>
</body>
</html>
